Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
Is it possible to get an "inverse" function of a Boolean function in javascript?

I was looking to write an "all-or-nothing" function over an array. One approach is, of course, to leverage Array.prototype.every and do something like

function allOrNothing(arr, f, fInv) {
  return arr.every(f) || arr.every(fInv);
}

where f and fInv are indicator functions, and fInv is an "inverse" function of f. For example, if f = (x) => x != null, then fInv = (x) => x == null.

This leads me to think: is it possible to get the function fInv from f?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This function, given a function f as an input, returns its boolean inverse:

let invert = (f) => (x) => !f(x)

e.g.

let invert = (f) => (x) => !f(x)

let eq_five = (x) => x == 5
let neq_five = invert(eq_five)

console.log(eq_five(5)) // true
console.log(neq_five(5)) // false

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda